<?php

/**
 * This file is part of the Pagizer package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @copyright   Copyright (c) 2010 Advisa (http://www.advisa.fr)
 * @author      Pagizer Core Team <team@pagizer.org>
 * @package     Pagizer
 * @subpackage  backoffice
 */

class m_backoffice_actions_AjaxGetBlockButtonsAction extends m_backoffice_extends_Action
{
	public function execute()
	{
        $pageService = m_website_services_PageService::getInstance();
		$blockId = $this->getRequestParameter("blockId");
		$docId = $this->getRequestParameter("docId");
		$docLang = strtolower($this->getRequestParameter("docLang"));
        $blockParams = $pageService->rawParamsToArray($this->getRequestParameter('blockParams'));
        
		if($this->getUserContext()->hasRight("website_BlockEdit"))
		{
            $page = f_document_Provider::getInstance()->getByModelAndUniqueId('website/Page', $docId, $docLang);
            $blockParams['blockId'] = $blockId;
            return $pageService->getBlockButtons($blockParams, $page, f_core_Context::getInstance()->getDisplayLang());
		}
	}	
	
	public function errorHandler()
	{
		return null;
	}
}